local binary93 = {}
local str = "123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()`~-_=+[]{}\\/|?;:'\",.<>"
local bstring = {}
local bstringindex = {}
for i = 1, string.len(str) do
    local s = string.sub(str, i, i)
    table.insert(bstring, i, s)
    bstringindex[s] = i
end
---10进制转93进制
binary93.b10to93 = function(b10, lenght)
    local st = ''
    local v = 0
    -- local vmax = math.floor(94 ^ (lenght or 0) - 1)
    -- if b10 > vmax then
    --     b10 = vmax
    -- end
    while b10 >= 94 do
        v = b10 % 94
        b10 = math.floor(b10 / 94)
        st = (bstring[v] or 0) .. st
    end
    st = (bstring[b10] or 0) .. st
    for i = 1, lenght - string.len(st) do
        st = '0' .. st
    end
    return st
end
---93进制转10进制
binary93.b93to10 = function(b93)
    local len = string.len(b93)
    local h = 0
    local i = 0
    while len >= 0 do
        i = i + 1
        local s = string.sub(b93, i, i)
        len = len - 1
        h = h + ((bstringindex[s] or 0) * (94 ^ len))
    end
    return math.floor(h)
end
return binary93
